package org.wlw.obj;

import java.util.Locale;

public class TestString {
    public static void main(String[] args) {
        String hello = "abcdefg";
        System.out.println(hello.charAt(3));
        System.out.println(hello.length());
        for(int i=0;i<hello.length();i++) {
            System.out.print(hello.charAt(i)+",");
        }
        System.out.println();
        System.out.println(hello.contains("aaa"));
        System.out.println(hello.contains("abc"));
        String fn = "hello.java";
        //取子串，包头不包尾
        System.out.println(fn.substring(2,5));
        //是否以.java结尾
        System.out.println(fn.endsWith(".java"));
        //找.dd在字符串中的位置，找不到的话会返回-1
        System.out.println(fn.indexOf(".dd"));
        //是否以hell开头
        System.out.println(fn.startsWith("hell"));
        String s2 = "Hello";
        System.out.println(s2.toLowerCase());
        System.out.println(s2.toUpperCase());
        String s3 = "    yeah    ";
        String s31 = s3.trim();//s3.trim()不会修改s3，
        System.out.println("|"+s31+"|");
    }
}
